<template>
	<view class="app">
		<view class="cell">
			<text class="tit fill">姓名</text>
			<input class="input" v-model="name" type="text" placeholder="请输入姓名"
				placeholder-style="color:#999;font-size:30rpx" />
		</view>
		<view class="cell">
			<text class="tit fill">手机号</text>
			<input class="input" v-model="phone" type="number" maxlength="11" placeholder="请输入手机号"
				placeholder-style="color:#999;font-size:30rpx" />
		</view>
		<view class="cell">
			<text class="tit fill">开户银行</text>
			<input class="input" v-model="bank" type="text"  placeholder="请输入开户银行"
				placeholder-style="color:#999;font-size:30rpx" />
		</view>
		<view class="cell">
			<text class="tit fill">开户卡号</text>
			<input class="input" v-model="bankcode" type="number"  placeholder="请输入开户卡号"
				placeholder-style="color:#999;font-size:30rpx" />
		</view>
		
		<!-- <view class="add-btn" @click="onclick">提交</view> -->
				<button class="add-btn" @click="onclick()" style="background-color: #FF5000 !important;color: #FFFFFF;width: 95%;margin: 0 auto;">提交</button>
		<pay-board ref="payJP" :showPrice='false' :showBoard="showBoard" @complete="complete"
			@closeBorad="showBoard = false"></pay-board>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				image: '',
				name: '',
				phone: '',
				bank:'',
				 bankcode:'',
				type: 'bank',
				showPwd: false,
				showBoard: false,
			}
		},
		onLoad() {
			this.$fun.ajax.post('user/banklist', {
				type: this.type
			}).then(res => {
				if (res.data.length>0 && res.code==1) {
					let month = res.data
					this.name = month[0].name
					this.bank = month[0].bank
					this.bankcode = month[0].bankcode
					this.phone = month[0].phone
					this.image = month[0].image
				}
			})
		},
		methods: {
			//选择头像
			chooseImage() {
				let _this = this;
				uni.chooseImage({
					count: 1,
					success: res => {
						uni.showLoading({
							title: '上传中',
						});
						const tempFilePaths = res.tempFilePaths;
						uni.uploadFile({
							url: this.$baseUrl + '/api/common/upload', // 仅为示例，非真实的接口地址 
							filePath: tempFilePaths[0],
							name: 'file',
							header: {
								token: uni.getStorageSync('token'),
								contentType: "application/json"
							},
							success(res) {
								var res = JSON.parse(res.data)
								_this.image = res.data.fullurl
								uni.showToast({
									title: "上传成功",
									icon: "none"
								});
								setTimeout(() => {
									uni.hideLoading()
								}, 1000);
							},
						})
					}
				});
			},
			complete(pass) {
				this.$fun.ajax.post('user/setPay',{
					paypwd: pass
				}).then(res => {
					this.$refs.payJP.password = ''
					if (res.code == 1) {
						this.showBoard = false
						this.upload()
					}
				})
			},
			upload() {
				let {
					name,
					phone,
				bank,
				 bankcode,
					type
				} = this;
				let parms = {
					name,
					phone,
					bank,
					 bankcode,
					type
				}
				this.$fun.ajax.post('user/setbank',{
					...parms
				}).then(res => {
					if (res.code == 1) {
						this.$fun.msg(res.msg)
						this.$fun.jump('',4,1200)
					}
				})
			},
			onclick() {
				let {
					name,
					phone,
				bank,
				 bankcode,
					type
				} = this;
				let parms = {
					name,
					phone,
					bank,
					 bankcode,
					type
				}
				if (!name) {
					this.$fun.msg('请输入姓名')
					return
				}
				if (!phone) {
					this.$fun.msg('请输入手机号')
					return
				}
				if (!bank) {
					this.$fun.msg('请输入开户银行')
					return
				}
				if (!bankcode) {
					this.$fun.msg('请输入开户卡号')
					return
				}
				this.showBoard = true
			}
		}
	}
</script>

<style lang="scss">
	.conter {
		text-align: center;
		margin-top: 30rpx;
		padding-bottom: 47rpx;
	}

	.imgewm {
		width: 351rpx;
		height: 350rpx;
		border-radius: 20rpx;
		margin: 0 auto;
	}

	.app {
		padding-top: 30rpx;
	}

	.nocell {
		border-bottom: none !important;
	}

	.cell {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		margin: 0 40rpx;
		border-bottom: 1px solid rgb(236, 236, 236);

		&:first-child {
			margin-bottom: 10rpx;
		}

		&:after {
			left: 40rpx;
			right: 40rpx;
			border-color: #d8d8d8;
		}

		.tit {
			font-size: 30rpx;
			color: #333;
		}

		.avatar-wrap {
			width: 120rpx;
			height: 120rpx;
			position: relative;
			border-radius: 100rpx;
			overflow: hidden;

			.avatar {
				width: 100%;
				height: 100%;
				border-radius: 100rpx;
			}

			.progress {
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translate(-50%, -50%);
				width: 100rpx;
				height: 100rpx;
				box-shadow: rgba(0, 0, 0, .6) 0px 0px 0px 2005px;
				border-radius: 100rpx;
				transition: .5s;
				opacity: 0;

				&.no-transtion {
					transition: 0s;
				}

				&.show {
					opacity: 1;
				}
			}
		}

		.input {
			flex: 1;
			text-align: right;
			font-size: 28rpx;
			color: #333;
		}

		switch {
			margin: 0;
			transform: scale(0.8) translateX(10rpx);
			transform-origin: center right;
		}

		.tip {
			margin-left: 20rpx;
			font-size: 28rpx;
			color: #999;
		}

		.checkbox {
			padding: 12rpx 0 12rpx 40rpx;
			font-size: 28rpx;
			color: #333;

			.mix-icon {
				margin-right: 12rpx;
				font-size: 36rpx;
				color: #ccc;
			}

			.icon-xuanzhong {
				color: $base-color;
			}
		}
	}
</style>
